package com.example.superoa.controller;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.superoa.common.Shijian;
import com.example.superoa.model.service.AttendMonthService;
import com.example.superoa.model.service.DemoService;
import com.example.superoa.model.vo.DeptVo;
import com.example.superoa.model.vo.StaffsVo;
import com.mysql.cj.xdevapi.JsonArray;

@Controller
public class Dem {
	@Autowired
	private DemoService biz;
	
	@Autowired
	private AttendMonthService a_biz;
	
	Shijian sj=new Shijian();
	
	@RequestMapping("select_sousuoKuang")
	@ResponseBody
	public JSONArray select_kuang(){
		JSONArray json=biz.selectKuang();
		int i=1;
		for (Object object : json) {
			JSONObject obj=(JSONObject)object;
			obj.put("sortable", i);
			i++;
		}
		return json;
	}
	@RequestMapping("select_zhiweiKuang")
	@ResponseBody
	public JSONArray select_zhiweiKuang(){
		JSONArray json=biz.selectposition();
		int i=1;
		for (Object object : json) {
			JSONObject obj=(JSONObject)object;
			obj.put("sortable", i);
			i++;
		}
		return json;
	}
	@RequestMapping("select_shijuan")
	@ResponseBody
	public JSONArray select_shijuan(){
		JSONArray json=biz.selectShijuan();
		int i=1;
		for (Object object : json) {
			JSONObject obj=(JSONObject)object;
			obj.put("sortable", i);
			i++;
		}
		return json;
	}
	@RequestMapping("select_ji")
	@ResponseBody
	public JSONArray select_ji(){
		JSONArray json=biz.selectJi();
		int i=1;
		for (Object object : json) {
			JSONObject obj=(JSONObject)object;
			obj.put("sortable", i);
			i++;
		}
		return json;
	}
	@RequestMapping("select_Shu")
	@ResponseBody
	public List<DeptVo> select_Shu(){
		List<DeptVo> vo=biz.selectShu();
		for (DeptVo dept : vo) {
			dept.setChecked(true);
			for (StaffsVo staff : dept.getChildren()) {
				staff.setChecked(true);
			}
		}
		return vo;
	}
	@RequestMapping("kq-attendance-month")
	public void demo1(HttpSession session) {
		a_biz.selectMont(new Date(sj.getNetworkTime()));
		session.setAttribute("month", new Date(sj.getNetworkTime()).getMonth()+1);
		session.setAttribute("year",new SimpleDateFormat("yyyy-MM-dd").format(new Date(sj.getNetworkTime())));
	}
	
	@RequestMapping("kq-attendance-rule")
	public void demo3() {
	}
	@RequestMapping("kq-business-assessor")
	public void demo4() {
	}
	@RequestMapping("kq-business-statiscal")
	public void demo5() {
	}
	@RequestMapping("kq-change-record")
	public void demo6() {
	}
	@RequestMapping("kq-clock")
	public void demo7() {
	}
	@RequestMapping("kq-leave-assessor")
	public void demo8() {
	}
	@RequestMapping("kq-leave-class")
	public void demo9() {
	}
	@RequestMapping("kq-leave-statistical")
	public void demo10() {
	}
	@RequestMapping("kq-overtime-assessor")
	public void demo11() {
	}
	@RequestMapping("kq-overtime-statistical")
	public void demo12() {
	}
	@RequestMapping("kq-repair-assessor")
	public void demo13() {
	}
	@RequestMapping("kq-vacation-manage")
	public void demo14() {
	}
	
	
}
